<?php

include "core/function.php";
include "core/conn.php";

$version = date_format(new DateTime(), 'YmdHm');
$url = "http://192.168.1.34/sk";
$path = "data";

$arr = array('v' => $version, 'items' => array(), 'users' => "");

if ($handle = opendir($path)) {
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != ".." && $entry != ".DS_Store") {
			$dummy = filesize($path."/".$entry) . "|"."$url/$path/$entry";
			array_push($arr['items'], $dummy);
        }
    }
    closedir($handle);
}

$userList = "";

$res = mysql_query("SELECT * from users");
while($r = mysql_fetch_array($res)){
	if($userList == "") {
		$userList .= $r['u'] . "," . $r['p'];
	} else {
		$userList .= "|" . $r['u'] . "," . $r['p'];
	} 
}


$arr['users'] = $userList;

echo json_encode($arr);

?>